package com.galeno.redis;

import redis.clients.jedis.Jedis;

import java.util.LinkedHashMap;
import java.util.Set;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/9/1421:22
 */
public class RedisHashAPI {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("galeno01",6379);
        LinkedHashMap<String, String> map = new LinkedHashMap<>();
        map.put("name","zhangsan");
        map.put("age","29");
        map.put("salary","22000");

        jedis.hset("haha",map);
        //查看所有
        System.out.println(jedis.hgetAll("haha"));
        //查看其中一个field
        System.out.println(jedis.hget("haha", "age"));
        //取得所有属性名字
        Set<String> haha = jedis.hkeys("haha");
        System.out.println(haha);
        //删除一个属性
        System.out.println(jedis.hdel("haha", "age"));
        System.out.println(jedis.hgetAll("haha"));

    }
}
